import { GBox } from "../../../../../com/mui/containers/GBox";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { FlyFootBmp } from "../flyFoot/FlyFootBmp";
import { TaskTargetInfo } from "../../../model/TaskTargetInfo";
import { EntityType } from "../../../rules/EntityType";
import { AIManager } from "../../../scene/ai/AIManager";
import { AIType } from "../../../scene/ai/AIType";
import { TBoss } from "../../../../../Message/Db/Tables/TBoss";
import { BossRefreshInfo } from "../../../model/BossRefreshInfo";
//class BossAreaListItem
    
    export  class BossAreaListItem /* flash.display.Sprite */
    {
        constructor()
        {
            
            buttonMode = true;
            this._body = new GBox();
            this._body.direction = GBoxDirection.HORIZONTAL;
            addChild(this._body);
            this._name = new Object /* flash.text.TextField */();
            this._name.selectable = false;
            this._name.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._name.textColor = 16776960;
            this._name.mouseEnabled = false;
            this._body.addChild(this._name);
            this._flyFootBmp = new FlyFootBmp();
            this._flyFootBmp.y = 2;
            this._body.addChild(this._flyFootBmp);
            addEventListener(flash.events.MouseEvent.CLICK, this.onFlyFootClickHandler);
            addEventListener(flash.events.MouseEvent.MOUSE_OVER, this.onMouseOverHandler);
            return;
        }

        /* internal  */onMouseOverHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            addEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            this._name.textColor = 65280;
            return;
        }

        /* internal  */onMouseOutHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            removeEventListener(flash.events.MouseEvent.MOUSE_OUT, this.onMouseOutHandler);
            this._name.textColor = 16776960;
            return;
        }

        /* internal  */onFlyFootClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (!this._target) 
            {
                this._target = new TaskTargetInfo();
            }
            this._target.mapId = this._boss.mapId;
            this._target.id = this._tboss.code;
            this._target.x = this._boss.px;
            this._target.y = this._boss.py;
            this._target.targetType = EntityType.Boss;
            if (typeof arg1.target === "flyfootbmp") 
            {
                AIManager.onAIControl(this._target, AIType.AI_Convey);
            }
            else 
            {
                AIManager.onAutoPathAIControl(this._target);
            }
            return;
        }

        public updateData(arg1: TBoss, arg2: BossRefreshInfo): void
        {
            this.dispose();
            if (arg2 != null) 
            {
                this._tboss = arg1;
                this._boss = arg2;
                this._name.textColor = 16776960;
                this._name.text = arg1.name + "(" + arg1.level + "级)";
                this._name.width = this._name.textWidth + 4;
                this._body.layChildChanged = true;
                this._body.invalidate();
            }
            return;
        }

        public dispose(): void
        {
            this._tboss = null;
            this._boss = null;
            return;
        }

        public /* override */ get width(): number
        {
            return this._name.width + this._flyFootBmp.width;
        }

        /* internal */ /* var */_body: GBox;

        /* internal */ /* var */_name: Object /* flash.text.TextField */;

        /* internal */ /* var */_flyFootBmp: FlyFootBmp;

        /* internal */ /* var */_target: TaskTargetInfo;

        /* internal */ /* var */_boss: BossRefreshInfo;

        /* internal */ /* var */_tboss: TBoss;
    }
